package neusoft.yuejian_11.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import neusoft.yuejian_11.base.BaseListAdapter;
import neusoft.yuejian_11.R;
import com.squareup.picasso.Picasso;

import java.util.List;

import neusoft.yuejian_11.bean.InformBean;
import neusoft.yuejian_11.viewHolder.InfomListViewHolder;

import static neusoft.yuejian_11.interF.Const.BASE_URI;

/**
 * Created by NEUSOFT on 2017/10/6.
 */

public class InforListAdapter extends BaseListAdapter {
    public InforListAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView=layoutInflater.inflate(R.layout.item_infor,parent,false);
        InfomListViewHolder holder=new InfomListViewHolder(itemView);
        return holder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        InfomListViewHolder infomListViewHolder=(InfomListViewHolder) holder;
        final InformBean informBean = (InformBean)data.get(position);

        final String inforname =informBean.getAdmin_name();
        String inforinfo=informBean.getI_info();
        String infortime=informBean.getI_createtime();
        String pic = BASE_URI+"photo/"+informBean.getAdmin_pic();
        Picasso.with(context)
                .load(pic)
                .placeholder(R.drawable.ic_cook_holder)
                .error(R.drawable.ic_cook_holder_error)
                .into(InfomListViewHolder.imageView);

        infomListViewHolder.infornameView.setText(inforname);
        infomListViewHolder.inforinfoView.setText(inforinfo);
        infomListViewHolder.infortimeView.setText(infortime);
    }

}
